import express from "express";
import * as videosController from "./videos.conteroller";
import { authGuard, userGuard } from "../auth/auth.middleware";
import { fileInterceptor, fileProcessor } from "./videos.middleware";

const router = express.Router();

/**
 * 获取
 */
router.get('/getVideo',userGuard, videosController.index);

/**
 * 按 user ID 获取
 */
router.get('/getVideoById/:userId', videosController.byIdIndex);

/**
 * 按 user ID 获取
 */
router.get('/videoById/:postId', videosController.videoById);

/**
 * 按关键字查询（模糊查询）
 */
router.get('/getVideoByKey', videosController.selectByKey);

/**
 * 创建
 */
router.post('/addVideo', authGuard, videosController.store);

/**
 * 点赞收藏
 */
router.post('/videoFavorite', authGuard, videosController.setFavorite);

/**
 * 上传文件
 */
router.post('/videoCoverFiles', authGuard, fileInterceptor, fileProcessor, videosController.uploads);

/**
 * 文件服务
 */
router.get('/videoCoverFiles/:fileId/serve', videosController.serve);

/**
 * 获取文件 ID
 */
router.post('/getVideoCoverFilesId', videosController.getFileName);

/**
 * 删除内容 
 */
router.delete('/video/:postId', authGuard, videosController.destroy);

/**
 * 修改状态
 */
router.patch('/videoStatus/:postId', authGuard, videosController.status);

/**
 * 导出路由
 */
export default router;
